#ifndef URL_H_
#define URL_H_

#include <string>
#include <cctype>
#include <boost/regex.hpp>

namespace crawler { namespace server {
class Url {
 public:
  Url(const std::string &url);
  const std::string GetScheme() { return scheme_; }
  const std::string GetUser() { return user_; }
  const std::string GetPassword() { return password_; }
  const std::string GetHost() { return host_; }
  const std::string GetPort() { return port_; }
  const std::string GetPath() { return path_; }
  const std::string GetQuery() { return query_; }
  const std::string GetRef() { return ref_; }
  const std::string GetFile() { return file_; }
  const std::string GetFileSuffix() { return file_suffix_; }
  const std::string GetDirectory() { return directory_; }
  int GetDepth() { return depth_; }
  bool IsValid() { return valid_; }
  std::string GetNormalized() { return normalized_; }
  std::string GetHrefLink(const std::string &href);

 private:
  std::string &ToLower(std::string &str) {
    for (size_t i=0; i<str.size(); ++i) str[i] = tolower(str[i]);
  }
  std::string url_;
  std::string scheme_;
  std::string user_;
  std::string password_;
  std::string host_;
  std::string port_;
  std::string path_;
  std::string query_;
  std::string ref_;
  std::string file_;
  std::string file_suffix_;
  std::string directory_;
  std::string normalized_;
  int         depth_;
  bool        valid_;

  static boost::regex s_url_regex_;
  static boost::regex s_path_regex_;
};
}}

#endif

